/**
 * 
 */
package com.hirstlogics.boxarrow.box;

import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.XMLStreamWriter;

import com.hirstlogics.boxarrow.xml.Persist;

/**
 * @author steve
 *
 */
public class ArrowSort extends AtomicBox {
	private boolean transitive=false;
	public boolean isTransitive() {
		return transitive;
	}
	public boolean isSymetric() {
		return symetric;
	}
	public boolean isReflexive() {
		return reflexive;
	}
	private boolean symetric=false;
	private boolean reflexive=false;
	
	public ArrowSort() {
	}
	
	public ArrowSort(String name, boolean isTransitive, boolean isSymetric, boolean isReflexive) {
		super(name);
		this.transitive=isTransitive;
		this.symetric=isSymetric;
		this.reflexive=isReflexive;
	}
	
	public void render(XMLStreamWriter writer) throws XMLStreamException {
		String myClass = this.getClass().getCanonicalName();
		writer.writeStartElement(Persist.PREFIX,"Box", Persist.BOXARROW);
		writer.writeAttribute("id", String.valueOf(getId()));
		writer.writeAttribute("sort", myClass);
		writer.writeAttribute("transitive", String.valueOf(isTransitive()));
		writer.writeAttribute("symetric", String.valueOf(isSymetric()));
		writer.writeAttribute("reflexive", String.valueOf(isReflexive()));
		writer.writeCharacters(getName());
		writer.writeEndElement();
	}


	public void readContents(XMLStreamReader reader) {
		String flag = reader.getAttributeValue(null,"transitive");
		transitive="true".equals(flag);
		flag = reader.getAttributeValue(null,"symetric");
		symetric="true".equals(flag);
		flag = reader.getAttributeValue(null,"reflexive");
		reflexive="true".equals(flag);
		super.readContents(reader);
	}

}
